<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include("../public/include/pagePidXf.class.php");
include "../public/include/funcs.php";
//include "./public/include/money.class.php";
//$obj_xf=new money($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$obj=new page($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
$type=$_REQUEST['type'];
$keyword=$_REQUEST['keyword'];
$pid=$_REQUEST['pid'];
$arr=$obj->listData("user join xiaofei on user.id=xiaofei.uid",15,$type,$keyword,$pid);
//$arr=$obj->listData("xiaofei",15,$type,$keyword,$pid);
$sel_arr[$type]="selected";
$date=date("Y-m");

$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);
if($pid=="all"){
	$title_name="所有分销商消费一览表";
}elseif($pid==0){
	$title_name="顶级分销商消费一览表";
}else{
	$self_arr=select($link, "user","id=$pid");
	$title_name=$self_arr[0]['tname']."的下级分销商消费列表";
}

/*foreach($arr as $k=>$v){
	$arr[$k]['self_xf']=$obj_xf->self_xf($v['id']);
	$arr[$k]['all_xf']=$obj_xf->all_xf($v['id']);
}*/

//echo "<pre>";
//print_r($arr);
//echo "</pre>";
?>
<html>
	<head>
		<meta charset="UTF-8">
		<title><?php echo $title_name;?></title>
		<link rel="stylesheet" type="text/css" href="../public/css/main.css"/>
	</head>
	<body>
<div class="tab">
	<h3><?php echo $title_name;?></h3>
	<form action="xiaofei.php" method="post">
		<input type="hidden" name="pid" value="<?php echo $pid;?>" />
		<select name="type">
			<option <?php echo $sel_arr['xftime']?> value="xftime">消费时间</option>
		</select>
		关键字：<input type="text" name="keyword" value="<?php echo $keyword?$keyword:$date;?>" />
		<input type="submit" value="搜索"/>
		<!--<a class="float_r" href="xiaofei.php?pid=all">查看所有消费列表</a>-->
	</form>
	<table border="1" cellspacing="0" cellpadding="0">
		<tr>
			<th>消费ID号</th>
			<th>用户ID号</th>
			<th>真实姓名</th>
			<th>用户名</th>
			<th>消费项</th>
			<th>消费金额</th>
			<th>备注</th>
			<th>消费时间</th>
		</tr>
<?php
foreach($arr as $v){
?>			
		<tr>
			<td><?php echo $v['id'];?></td>
			<td><?php echo $v['pid'];?></td>
			<td><?php echo $v['tname'];?></td>
			<td><?php echo $v['nickname'];?></td>
			<td><?php echo $v['porject'];?></td>
			<td><?php echo $v['money'];?></td>
			<td><?php echo $v['beizhu'];?></td>
			<td><?php echo $v['xftime'];?></td>
		</tr>
<?php
}
?>	
		<tr>
			<td colspan="10">
				<?php echo $obj->showPage();?>
			</td>
		</tr>		
	</table>
</div>
	</body>
</html>